1. Field of the Invention
The present invention relates to a microcontroller.
2. Description of Related Art
A technology for a microcontroller having a voltage detection function is disclosed in Japanese Unexamined Patent Application Publication No. 62-80716. A microcontroller 1 disclosed in Japanese Unexamined Patent Application Publication No. 62-80716 includes a reset circuit 2 and a CPU 3. The reset circuit 2 includes voltage detecting ICs 21 and 22. The CPU 3 includes an internal RAM 31 which is a memory for saving resister information.
When a power supply voltage VA is equal to or lower than a predetermined voltage VR, each of the voltage detecting ICs 21 and 22 outputs a non-maskable interrupt (NMI) signal Vnmi, which is a low-level interrupt signal, to the CPU 3. Note that the predetermined voltage VR is set to a voltage value at which the microcontroller 1 can normally operate. Further, the NMI signal Vnmi is low active.
When the power supply voltage VA drops, the voltage detecting IC 21 outputs the NMI signal Vnmi of low level to the CPU 3. Upon receiving the NMI signal Vnmi, the CPU 3 performs a pre-backup processing operation for saving register information in the internal RAM 31 according to an interrupt routine. After that, when the power supply voltage VA is equal to or lower than a voltage V1, which is lower than the voltage VR, an output signal Vstnby of the voltage detecting IC 22 is set to low level, thereby shifting the CPU 3 to the standby state. Note that the above-mentioned pre-backup processing operation requires at least a period of time to save the register information in the internal RAM 31, and the time necessary for the pre-backup processing operation is set as a period Tpo. To secure the period Tpo, the capacity of a smoothing capacitor of a power supply circuit that supplies the power supply voltage VA is set.
As described above, when the power supply voltage VA fluctuates and decreases to a voltage lower than the voltage VR, the microcontroller 1 saves information necessary for the RAM 31 from the CPU 3 and backs up data.